package cn.edu.scau.cmi.zhangmingxing.client;
import javafx.scene.*;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import cn.edu.scau.cmi.zhangmingxing.simpleFactoryMethod.MeatFactory;
import cn.edu.scau.cmi.zhangmingxing.simpleFactoryMethod.domain.Chicken;
import cn.edu.scau.cmi.zhangmingxing.simpleFactoryMethod.domain.Meat;
import cn.edu.scau.cmi.zhangmingxing.singleton.President;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.stage.Stage;

public class SimpleFactoryMethodClient extends Application{
	public void start(Stage primaryStage) {
		primaryStage.setTitle("SimpleFactory");
		Group root=new Group();
		HBox btn=new HBox();
		btn.setLayoutX(20);
		btn.setLayoutY(20);
		TextArea area=new TextArea();
		area.setLayoutX(10);
		   area.setLayoutY(65);
		   area.setMaxHeight(240);
		   area.setMaxWidth(550);
		   area.setEditable(false);
		Button btn1=new Button();
		btn1.setText("chicken");
		Button btn2=new Button();
		btn2.setText("pork");
		Button btn3=new Button();
		btn3.setText("beef");
		btn.setSpacing(40);
		btn.setAlignment(Pos.CENTER);
		btn1.setOnAction(new EventHandler<ActionEvent>() {
	        @Override
	        public void handle(ActionEvent event) {
	        	Meat chicken=MeatFactory.getMeat("chicken");
	        	area.appendText(chicken.cook());
	        }
	    });
		btn2.setOnAction(new EventHandler<ActionEvent>() {
			public void handle(ActionEvent event) {
				Meat pork=MeatFactory.getMeat("pork");
				area.appendText(pork.cook());
			}
		});
		btn3.setOnAction(new EventHandler<ActionEvent>() {
			public void handle(ActionEvent event) {
				Meat beef=MeatFactory.getMeat("beef");
				area.appendText(beef.cook());
			}
		});
		btn.getChildren().addAll(btn1,btn2,btn3);
		root.getChildren().addAll(area,btn);
		Scene scene=new Scene(root,500,300,Color.rgb(0, 0, 0,0));
		primaryStage.setScene(scene);
		primaryStage.show();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		launch(args);
	}

}
